package com.dys.service.impl;

import com.dys.mapper.RoleMapper;
import com.dys.pojo.Role;
import com.dys.pojo.RoleExample;
import com.dys.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: com.dys.service.impl.RoleServiceImpl
 * @description: com.dys.service.impl
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/11/15 20:27
 */
@Service
public class RoleServiceImpl implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> listRoleInfoByRole(Role role) throws Exception {
        RoleExample roleExample = new RoleExample();
        return roleMapper.selectByExample(roleExample);
    }

    @Override
    public int addRoleInfo(Role role) throws Exception {
        return roleMapper.insertSelective(role);
    }

    @Override
    public int updateRoleInfo(Role role) throws Exception {
        return roleMapper.updateByPrimaryKeySelective(role);
    }

    @Override
    public int deleteRoleInfo(int roleId) throws Exception {
        return roleMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public Role getRoleInfoByRoleId(int roleId) throws Exception {
        return roleMapper.selectByPrimaryKey(roleId);
    }
}
